﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Model;

namespace MyStudentProj
{
    public partial class ScoreForm : Form
    {
        public ScoreForm()
        {
            InitializeComponent();
        }
        public int ScoreID { get; set; }

        public ScoreForm(Score score) : this()
        {
            if (score != null)
            {
                this.Text = "修改";
                
                ScoreID = score.ScoreID;
                txtStudentID.Text = score.StudentID.ToString();
                txtCourseID.Text = score.CourseID.ToString();
                txtScoreValue.Text = score.ScoreValue.ToString();
                dtpExamDate.Value = Convert.ToDateTime(score.ExamDate);
                if (score.ScoreType.ToString() == "期中")
                {
                    rbtnMidExam.Checked = true;
                }
                else if (score.ScoreType.ToString() == "期末")
                {
                    rbtnFinalExam.Checked = true;
                }
                dtpCreateDate.Value = Convert.ToDateTime(score.CreateDate);
            }
            else
            {
                this.Text = "新增";
            }

        }

        public string StudentID => txtStudentID.Text;
        public string CourseID => txtCourseID.Text;
        public string ScoreValue => txtScoreValue.Text;
        public string ExamDate => dtpExamDate.Value.ToString();
        public string ScoreType => rbtnMidExam.Checked ? rbtnMidExam.Text : rbtnFinalExam.Text;
        public string CreateDate => dtpCreateDate.Value.ToString();

        private void btnEdit_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
    }
}
